import request from '@/config/axios'

// ERP 库存调拨单 VO
export interface StocksMoveVO {
  id: number // 调拨编号
  no: string // 调拨单号
  fromWarehouseId: number // 调出仓库编号
  toWarehouseId: number // 调入仓库编号
  moveTime: Date // 调拨时间
  remark: string // 备注
  status: number // 状态
  processInstanceId: string // 流程实例的编号
}

// ERP 库存调拨单 API
export const StocksMoveApi = {
  // 查询ERP 库存调拨单分页
  getStocksMovePage: async (params: any) => {
    return await request.get({ url: `/erp/stocks-move/page`, params })
  },

  // 查询ERP 库存调拨单详情
  getStocksMove: async (id: number) => {
    return await request.get({ url: `/erp/stocks-move/get?id=` + id })
  },

  // 新增ERP 库存调拨单
  createStocksMove: async (data: StocksMoveVO) => {
    return await request.post({ url: `/erp/stocks-move/create`, data })
  },

  // 修改ERP 库存调拨单
  updateStocksMove: async (data: StocksMoveVO) => {
    return await request.put({ url: `/erp/stocks-move/update`, data })
  },

  // 删除ERP 库存调拨单
  deleteStocksMove: async (id: number) => {
    return await request.delete({ url: `/erp/stocks-move/delete?id=` + id })
  },

  // 导出ERP 库存调拨单 Excel
  exportStocksMove: async (params) => {
    return await request.download({ url: `/erp/stocks-move/export-excel`, params })
  },
  // 新增二级库存以及台账
  createStocksOnMoveItem: async (data: any) => {
    return await request.post({ url: `/erp/stocks-move/create-stocks-on-move-item`, data })
  },

// ==================== 子表（ERP 库存调拨项） ====================

  // 获得ERP 库存调拨项列表
  getStocksMoveItemListByMoveId: async (moveId) => {
    return await request.get({ url: `/erp/stocks-move/stocks-move-item/list-by-move-id?moveId=` + moveId })
  },
}
